﻿@using Smartstore.Admin.Models.Messages

@model CampaignModel

@{
    ViewBag.Title = T("Admin.Promotions.Campaigns.EditCampaignDetails").Value;
}

<form asp-action="Edit">
    <div class="section-header">
        <div class="title">
            <a sm-backto asp-action="List"></a>
            <span>@T("Admin.Promotions.Campaigns.EditCampaignDetails") - @Model.Name</span>
        </div>
        <div class="options">
            @if (Model.Id > 0)
            {
                <button type="submit" id="send-campaign" name="send-campaign" value="send-campaign" class="btn btn-outline-secondary btn-to-primary px-5 mr-3">
                    <i class="fa fa fa-envelope"></i>
                    <span>@T("Common.Send")</span>
                </button>
                <confirm message="@T("Common.AreYouSure")" button-id="send-campaign" icon="fas fa-question-circle" action="SendCampaign" type="Action" />
                <a id="btn-preview-template" class="btn btn-secondary" asp-action="Preview" asp-controller="MessageTemplate" asp-route-id="@Model.Id" asp-route-isCampaign="true">
                    <i class="far fa-eye"></i>
                    <span>@T("Admin.Common.Preview")</span>
                </a>
            }
            <button type="submit" name="save" value="save" class="btn btn-warning">
                <i class="fa fa-check"></i>
                <span>@T("Admin.Common.Save")</span>
            </button>
            <button type="submit" name="save" value="save-continue" class="btn btn-secondary">
                <span>@T("Admin.Common.SaveContinue")</span>
            </button>
            <button type="submit" name="campaign-delete" id="campaign-delete" class="btn btn-danger">
                <i class="far fa-trash-alt"></i>
                <span>@T("Admin.Common.Delete")</span>
            </button>
            <confirm button-id="campaign-delete" />
        </div>
    </div>

    <partial name="_CreateOrUpdate" model="Model" />
</form>

<script>
	$(function () {
		$('#btn-preview-template').on('click', function (e) {
			e.preventDefault();
			openPopup($(this).attr('href'), false /* large */, true /* flex */);
			return false;
        });

        $(window).keydown(function (event) {
            if ((event.keyCode == 13)) {
                event.preventDefault();
                return false;
            }
        });
	});
</script>
